{##
 # TODO: description
 #
 # @copyright  Copyright (c) 2010-2011 The Fajr authors (see AUTHORS).
 #             Use of this source code is governed by a MIT license that can be
 #             found in the LICENSE file in the project root directory.
 # @author     TODO
 #}
{% extends "layout/studium.xhtml" %}
{% block title %}Moje skúšky{% endblock %}
{% block application_content %}
{% import "macros/decorators.xhtml" as decorators %}
{% import "macros/table.xhtml" as table %}
{% import "macros/studium.xhtml" as studiumMacros %}
{{ parent() }}
{% set tabContent %} 

  {% macro tabulkaSkuska(row, odhlas, studium, zapisnyList, action) %}
    {% url link for {'action': action,
                     'studium': studium,
                     'list': zapisnyList,
                     'termin': row.index} %}
    {% import "macros/decorators.xhtml" as decorators %} 
    {% set title %}
      {{decorators.span(row.predmetNazov~" - "~row.dat,"table_box_title")}}
    {% endset %}
    {% set content %}
    <div class="table_box">
      <ul class="table_box">     
        {#{ decorators.riadok("Predmet:", "<a href="~link~">"~row.predmetNazov~"</a>") }#}
        {{ decorators.riadok("Čas:", row.cas) }}
        {{ decorators.riadok("Dátum:", row.dat) }}
        {{ decorators.riadok("Miestnosť:", row.miestnosti) }}
        {{ decorators.riadok("Hodnotiaci:", row.hodnotiaci) }}
        {{ decorators.riadok("Počet prihlásených:", row.pocetPrihlasenych) }}
        {{ decorators.riadok("Maximálny počet:", row.maxPocet) }}
        {{ decorators.riadok("Poznámka:", row.poznamka) }}
        {{ decorators.riadok("Prihlasovanie:", row.prihlasovanie) }}
        {{ decorators.riadok("Odhlasovanie:", row.odhlasovanie) }}
        {{ decorators.riadok("Odhlás:", odhlas) }}
        {{ decorators.riadok("Známka:", row.znamka) }}
        <li><a href={{link}} class="last">Zoznam prihlásených</a></li>
      </ul>      
    </div>
    {% endset %}      
    {{ decorators.collapsible(title, content, true) }}
  {% endmacro %}

 
  {% set body %}
    {% for row in terminyActive %}      
        {% if row.mozeOdhlasit %}
          {% set class="terminmozeodhlasit" %}
          {% url formAction for {'action': 'studium.OdhlasZoSkusky',
                                 'studium': studium,
                                 'list': zapisnyList} %}
          {% set odhlas %}
            <form method="post" action="{{ formAction }}">
              <div>
                <input type="hidden" name="odhlasIndex" value="{{ row.index }}" />
                <input type="hidden" name="hash" value="{{ row.hashNaOdhlasenie }}"/>
                <button name="submit" type="submit" class="tableButton negative">
                  <img src="images/third_party/silk/cross.png" alt="" />Odhlás
                </button>
              </div>
            </form>
          {% endset %}
        {% else %}
          {% set class="terminnemozeodhlasit" %}
          {% set odhlas="nedá sa" %}
        {% endif %}
        {% if row.jePrihlaseny != 'TRUE' %}
          {% set class="terminodhlaseny" %}
          {% set odhlas="Si odhlásený. Ak chceš, opäť sa prihlás." %}
        {% endif %}
        {{ _self.tabulkaSkuska(row,  odhlas, studium, zapisnyList, action) }}      
    {% endfor %}
  {% endset %}  

  {% set title %}
    <h2>Aktuálne termíny hodnotenia</h2>
  {% endset %}

  {% set tableHTML %}
  {{ decorators.printbox(body, terminyActive|length == 0) }}  
  {% endset %}

  {{ decorators.collapsible(title, tableHTML, false) }}

  {# -- stare terminy #}

  {% set body %}
    {% for row in terminyOld %}      
        {{ _self.tabulkaSkuska(row, "Skúška už bola.", studium, zapisnyList, action) }}      
    {% endfor %}
  {% endset %}

  {% set title %}
    <h2>Staré termíny hodnotenia</h2>
  {% endset %}

  {% set tableHTML %}
  {{ decorators.printbox(body, terminyOld|length == 0) }}
  {% endset %}

  {{ decorators.collapsible(title, tableHTML, false) }}

  {# -- zoznam prihlasenych na termin #}
  {{ studiumMacros.zoznamPrihlasenych(prihlaseni) }}

{% endset %}

{{ studiumMacros.studiumTabs(tabContent, 'TerminyHodnotenia', studium, zapisnyList) }}

{% endblock %}
